# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contribtor: Achmad Fathoni <fathoni.id(at)gmail.com>

_pkgname=papermill
pkgname="python-${_pkgname}"
pkgver=2.4.0
pkgrel=3
pkgdesc="Parametrize and run Jupyter and nteract Notebooks"
arch=('any')
url="https://pypi.org/project/${_pkgname}"
license=('BSD')
makedepends=(python-build python-installer python-wheel python-setuptools-scm)
checkdepends=(python-pytest python-boto3 python-moto)
depends=(
    python
    python-ansiwrap
    python-click
    python-pyyaml
    jupyter-nbformat
    jupyter-nbclient
    python-tqdm
    python-requests
    python-entrypoints
    python-tenacity
)
optdepends=('python-boto3: AWS functionality')
source=("${_pkgname}-${pkgver}.tar.gz::https://github.com/nteract/${_pkgname}/archive/refs/tags/${pkgver}.tar.gz")
b2sums=('ffbc08bcc75ad01721b503e7eb9033ee4131852c3813f3a1e40db60eab9ca210322ed05e6d9d0ef7f023bffce8278f181a542cee6f4fb711a10d6534c061be12')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  python -m build --wheel --no-isolation
}

check() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  # drop test files we cannot load
  PYTHONPATH="${PWD}/build/lib:${PWD}/src" pytest --continue-on-collection-errors \
    --ignore-glob='papermill/tests/test_abs.py' --ignore-glob='papermill/tests/test_adl.py' \
    -k 'not gcs_fallback_retry and not gcs_handle_exception and not gcs_retry and not hdfs_listdir'
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -D LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}
